#pragma once
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>

enum
{
    OK,
    MKFIFOERR,
    UNLINKERR,
    OPENERR
};

const mode_t gmode = 0600;
const char* gpath = "./fifo";

int Openpipe(int flag)
{
    int fd = ::open(gpath, flag);
    if (fd < 0)
    {
        std::cout << "打开管道失败" << std::endl;
        return -1;
    }
    return fd;
}

void CloseHelper(int fd)
{
    if(fd > 0) 
        ::close(fd);
}
